<template>
    <el-dialog :visible.sync="deletshow" width="50%" :show-close="false" :close-on-click-modal="false">
        <span>是否删除</span>
        <span slot="footer" class="dialog-footer">
            <el-button @click="deletefalse">取 消</el-button>
            <el-button type="primary" @click="deletetrue">确 定</el-button>
        </span>
    </el-dialog>
</template>
<script>
import { getData, getWork } from '@/api/table'
import { Message } from 'element-ui'

export default {
    name: '',
    components: {

    },
    mixins: [],
    props: {
        deletshow: {
            type: Boolean,
            required: true
        },
        selectList: {
            type: Array,
            required: true
        },
        deleteurl: {
            type: String,
            required: true
        },
    },
    data() {
        return {
            formdata: '',
        }
    },
    computed: {

    },
    watch: {

    },
    mounted() {

    },
    methods: {
        // 确定
        deletetrue() {
            this.formdata = ''
            this.formdata = new FormData()
            // console.log(this.selectList);
            if (this.$route.name == 'Equipment') {
                this.formdata.append('equipmentIds', this.selectList.join())
            }
            if (this.$route.name == 'User') {
                this.formdata.append('userIds', this.selectList.join())
            }
            if (this.$route.name == 'Workorder') {
                this.formdata.append('workOrderIds', this.selectList.join())
            }
            if (this.$route.name == 'handle') {
                this.formdata.append('ids', this.selectList.join())
            }
            if (this.$route.name == 'feedback') {
                this.formdata.append('ids', this.selectList.join())
            }
            if (this.$route.name == 'Modu') {
                this.formdata.append('modId', this.selectList.join())
            }
            // console.log(this.deleteurl);
            getData(this.deleteurl, 'POST', this.formdata).then(res => {
                Message({
                    message: res.msg,
                    type: 'success',
                    duration: 3 * 1000
                })
                if (this.$route.name == 'Modu') {
                    let deleModu = {}
                    let getUrl = '/module/index'
                    getWork(getUrl, 'get').then(res1 => {
                        deleModu = res1
                        this.$emit('purview-delemodu', { deleModu });
                    });
                }
            })
            this.$emit('delete-event', false);
        },
        // 取消
        deletefalse() {
            this.$emit('delete-event', false);
        }
    }
};
</script>
<style lang='' scoped>
</style>